class Animal{
    public String name;
    public int age;


    public Animal(String name,int age){
        this.name = name;                      //被private.final.static修饰的方法不能被重写
                                                //想要重写方法，子类的方法访问限定权限必须大于等于父类方法的访问限定权限
        this.age = age;                 //当我们引用的对象不一样，调用同一个重写的方法，展现出来的行为不一样，这种就叫多态
    }
    public void eat(){
        System.out.println(name+"正在吃!");
    }

    @Override
    public String toString() {
        return "Animal{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
class Dog extends Animal{
    public Dog(String name,int age){
        super(name,age);
    }
    public void wangWang(){
        System.out.println(name+"正在旺旺!");
    }
}
class Bird extends Animal {
    public Bird(String name, int age) {
        super(name, age);
    }

    public void fly() {
        System.out.println(name + "正在飞!");
    }
}

public class Test {
    public static void main(String[] args) {
        Dog dog = new Dog( "小狗",10);
        dog.eat();
        dog.wangWang();
        System.out.println("===");
        Animal animal = new Animal( "animal",10);
        animal.eat();
    }
}

